import request from '@/config/axios'
import type { Dayjs } from 'dayjs'

/** 设备类型信息 */
export interface CompanyDeviceType {
  id: number // id
  name?: string // 类型名称
  parentId?: number // 父类型id
  sort?: number // 显示顺序
  dutyUserId?: string // 负责人
  dutyUserName?: string // 负责人姓名
  status?: number // 部门状态（0正常 1停用）
  children?: CompanyDeviceType[]
}

// 设备类型 API
export const CompanyDeviceTypeApi = {
  // 查询设备类型列表
  getCompanyDeviceTypeList: async (params) => {
    return await request.get({ url: `/business/company-device-type/list`, params })
  },

  // 查询设备类型详情
  getCompanyDeviceType: async (id: number) => {
    return await request.get({ url: `/business/company-device-type/get?id=` + id })
  },

  // 新增设备类型
  createCompanyDeviceType: async (data: CompanyDeviceType) => {
    return await request.post({ url: `/business/company-device-type/create`, data })
  },

  // 修改设备类型
  updateCompanyDeviceType: async (data: CompanyDeviceType) => {
    return await request.put({ url: `/business/company-device-type/update`, data })
  },

  // 删除设备类型
  deleteCompanyDeviceType: async (id: number) => {
    return await request.delete({ url: `/business/company-device-type/delete?id=` + id })
  },

  // 导出设备类型 Excel
  exportCompanyDeviceType: async (params) => {
    return await request.download({ url: `/business/company-device-type/export-excel`, params })
  }
}
